const sql = require("../sql/mysql");
const users = require("../sql/users");
const jwt = require("jsonwebtoken");

module.exports = (req,res)=>{

    const token = req.headers.authorization
    
    jwt.verify(token,"大聪明",(err,data)=>{
        if(err){
            res.send({code:1,msg:"登录失效，请重新登录"})
        }else{
            // sql.get(users,{username:data.username}).then(result=>{
                
            //     if(result.length>0){   //result为sql.get返回的数组
            //         // console.log(result[0].username);
            //         sql.get(users,{username:result[0].username},{password:pw.newpw}).then(endres=>{
            //             res.send({code:0,msg:"修改成功"})
            //         })
            //     }else{
            //         res.send({code:2,msg:"原密码错误"})
            //     }
            // })
            sql.get(users,{username:data.username}).then(result=>{
                res.send({
                    code:0,
                    msg:"获取成功",
                })
            })
        }
    })
}